// src/vuex/store.js
import { createStore } from 'vuex'

const state = {
  isPractice: false, //练习模式标志
  flag: false,       //菜单栏左右滑动标志
  userInfo: null,
  menu: [
    {
      index: '1',
      title: '考试管理',
      icon: 'icon-kechengbiao',
      content: [
        { item1: '功能介绍', path: '/index/examDescription' },
        { item2: '考试查询', path: '/index/selectExam' },
        { item3: '添加考试', path: '/index/addExam' }
      ]
    },
    {
      index: '2',
      title: '题库管理',
      icon: 'icon-tiku',
      content: [
        { item1: '功能介绍', path: '/index/answerDescription' },
        { item2: '所有题库', path: '/index/selectAnswer' },
        { item3: '增加题库', path: '/index/addAnswer' },
        { path: '/index/addAnswerChildren' }
      ]
    },
    {
      index: '3',
      title: '成绩查询',
      icon: 'icon-performance',
      content: [
        { item1: '学生成绩查询', path: '/index/allStudentsGrade' },
        { path: '/grade' },
        { item2: '成绩分段查询', path: '/index/selectExamToPart' },
        { path: '/scorePart' }
      ]
    },
    {
      index: '4',
      title: '学生管理',
      icon: 'icon-role',
      content: [
        { item1: '学生管理', path: '/index/studentManage' },
        { item2: '添加学生', path: '/index/addStudent' }
      ]
    },
    {
      index: '5',
      title: '教师管理',
      icon: 'icon-Userselect',
      content: [
        { item1: '教师管理', path: '/index/teacherManage' },
        { item2: '添加教师', path: '/index/addTeacher' }
      ]
    },
    // {
    //   index: '7',
    //   title: '模块管理',
    //   icon: 'icon-module4mokuai',
    //   content: [{ item1: '模块操作', path: '/module' }]
    // }
  ]
}

const mutations = {
  practice(state, status) {
    state.isPractice = status
  },
  toggle(state) {
    state.flag = !state.flag
  },
  changeUserInfo(state, info) {
    state.userInfo = info
  },
  sendIndex(state, index) {
    state.index1 = index
  }
}

const actions = {
  getUserInfo({ commit }, info) {
    commit('changeUserInfo', info)
  },
  getPractice({ commit }, status) {
    commit('practice', status)
  }
}

const getters = {
  // 可添加需要的 getter
}

export default createStore({
  state,
  mutations,
  actions,
  getters
})
